<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Table</title>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/begtable.css" />
    <style>
        .layui-form-item{
            padding: 5px 4px;
            margin-bottom: 0;
            clear: both;
            *zoom: 1;
        }
        .layui-elem-quote{
            padding:5px;
        }
        .beg-table-box {
            position: inherit;
        }
        .beg-table-body {
            overflow-x: scroll;
            /* width: 2000px; */
            max-height: 100%;
            width: 100%;
        }
        .beg-table {
            /* width: 100%; */
            /* max-width: 100%; */
            height: 100%;
            margin-bottom:0px;
        }
        td,th{white-space: nowrap; }
        td{font-size:13px;text-align: center;}
        td:first-child{

        }
        .text-input{
            margin:0;
            padding: 0;
            border: 0;
            border-bottom:1px solid #777;
            width:100%;
            height: 100%;
            font-size: 15px;
        }
        .edit{}
        .time{}
        .img{}
        .item{}
        .modify{}
    </style>
</head>

<body>
<div class="admin-main">
    <form class="layui-form" action="" id="searchForm" method="post">
        <input type="hidden" name="currentPage" id="currentPage" value="${bo.currentPage}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">页面id</label>
            <div class="layui-input-inline">
                <input class="layui-input" name="pageId" type="number" value="${bo.pageId!}">
            </div>
            <label class="layui-form-label">页面类型</label>
            <div class="layui-input-inline">
                <select name="type">
                    <option value="">未选择</option>
                    <option value="0" <#if bo.type == 0>selected</#if>>DIY页面</option>
                    <option value="1" <#if bo.type == 1>selected</#if>>标准页面</option>
                    <option value="2" <#if bo.type == 2>selected</#if>>外链页面</option>
                </select>
            </div>
        </div>
    </form>

    <blockquote class="layui-elem-quote">
        <a href="javascript:;" class="layui-btn layui-btn-small" id="search">
            <i class="layui-icon">&#xe615;</i> 搜索
        </a>
        <button class="layui-btn layui-btn-small" onclick="alertWindow('/diy/newpage.htm?type=1','新增标准页面')">
            <i class="layui-icon">&#xe615;</i> 新增标准页面
        </button>
        <button class="layui-btn layui-btn-small" onclick="alertWindow('/diy/newpage.htm?type=0', '新增DIY页面')">
            <i class="layui-icon">&#xe615;</i> 新增DIY页面
        </button>
        <button class="layui-btn layui-btn-small" onclick="alertWindow('/diy/newpage.htm?type=2', '外链页面')">
            <i class="layui-icon">&#xe615;</i> 外链页面
        </button>
    </blockquote>

    <div id="xx" style="border: 1px solid #DDDDDD;">
        <div style="border: 1px solid #009688;" class="tablediv">
            <div class="beg-table-box">
                <div class="beg-table-body">
                    <table class="beg-table beg-table-bordered beg-table-striped beg-table-hovered">
                        <thead>
                        <tr>
                            <th>pageID</th>
                            <th>标题</th>
                            <th>是否菜单</th>
                            <th>页面类型</th>
                            <th>搜索条件</th>
                            <th>权限</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list pager.content as diyPage>
                            <tr>
                                <td>${diyPage.pageId}</td>
                                <td>${diyPage.title}</td>
                                <td>${diyPage.imMenu?string("是", "否")}</td>
                                <td>
                                <#if diyPage.type == 0>
                                    通版
                                <#elseif diyPage.type == 1>
                                    DIY
                                <#elseif diyPage.type == 2>
                                    外链
                                </#if></td>
                                <td>${diyPage.fieldMap}</td>
                                <td>${diyPage.permissions}</td>
                                <td >
                                    <button class="layui-btn layui-btn-mini" onclick="alertWindow('/diy/newpage.htm?type=${diyPage.type}&id=${diyPage.pageId}', '编辑页面')">编辑</button>
                                    <button class="layui-btn layui-btn-mini" onclick="deletePage(${diyPage.pageId})">删除</button>
                                </td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                </div>
                 <div class="beg-table-paged"></div>
            </div>
        </div>
    </div>
    <hr>
</div>
<script type="text/javascript" src="/js/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/plugins/layui/layui.js"></script>
<script type="text/javascript" src="/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/js/custom_common.js"></script>
<script>

    layui.config({
        base: '/js/'
    });

    layui.use(['begtable', 'laydate'], function() {
        var laydate = layui.laydate;
        $(".beg-table-box").height($(window).height() - 180);
        $(window).on('resize', function(){
            $(".beg-table-box").height($(window).height() - 180);
        });

    });

    layui.use(['form', 'layedit','laypage', 'laydate'], function() {
        var form = layui.form(),laypage = layui.laypage;


        var totalPage = '${pager.totalPages!}';
        var currentPage = '${pager.number}';
        //page
        laypage({
            cont: $('.beg-table-paged'),
            curr:parseInt(currentPage),
            pages: parseInt(totalPage) //总页数
            ,
            groups: 10 //连续显示分页数
            ,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                    //layer.msg('第 '+ obj.curr +' 页');
                    $("#currentPage").val(parseInt(curr));
                    $("#searchForm").submit();
                }else{
                    layer.msg('第 '+ obj.curr +' 页');
                }
            }
        });

        $('#search').on('click', search);
    });

    function search() {
        $('#currentPage').val(1);
        $("#searchForm").submit();
    }

    function deletePage(id){
        if (confirm("确认删除["+id+"]页面？")) {
            $.post("/diy/delPages.json", {pageId: id}, function (data) {
                if (data.result === 'success') {
                    location.reload();
                } else layer.msg(data.msg);
            });
        }
    }
</script>
</body>
</html>